const koa = require('koa');
const app = new koa();
const render = require('koa-art-template');
const router = require('koa-router')();
const path = require('path')
const DB = require('./modules/db');

app.use(router.routes()).use(router.allowedMethods());
render(app, {
    root: path.join(__dirname, 'views'),
    extname: '.html', //后缀也可以写成.art
    debug: process.env.NODE_ENV !== 'production'
});
router.get('/', async ctx => {
    var data = await DB.find("user", {});
    console.log(data);
    await ctx.render('index', {
        data
    })
})
router.get('/detail', async ctx => {
    await ctx.render("detail", {
        detail: "详情"
    })
})
app.listen(8080)